#ifndef EI_MAGACC_H
#define EI_MAGACC_H

#include <list>
#include <Ogre.h>

#include "include/KalmanFilters.h"
#include "include/VectorObject.h"

namespace Ei {

using namespace Ogre;

class MagAcc {

protected:
	
	// internal Methods
	void splitGravityAndAcceleration(Vector3 data);
	void setupVectorObjects();
	void loadSettings();
	
	// data in sensor coordinate system
	Vector3 mNorth;
	Vector3 mGravity;
	Vector3 mIntergratedGravity;
	Vector3 mVelocity;
	Vector3 mAcceleration;
	Quaternion filterOffset;
	
	// filters 
	VelocityInterpolator mVeloFilter[3];
	NoiseFilter mMagNoiseFilter[3];
	NoiseFilter mMagMoveFilter[3];
	NoiseFilter mAccNoiseFilter[3];
		
public:
	MagAcc();
        ~MagAcc();
	
	//used by App
	void       calibrateSensor();
	Quaternion getOrientation();
	Vector3    getVelocity();
	void	   update(float dt);
	
	// used by Netmanager	
	void insertMagData(Vector3 newData);
	void insertAccData(Vector3 newData);

 	// used by Gui
 	void calculateOffset(); 
 	void measureExtremes(Vector3 data);
 	void resetFilters(int filterset);
		
	int useFilter; 
	bool mCalibrated; 
	
	// settings and debug information
	std::map<std::string, Real> mSettings; 
	std::map<std::string, VectorObject*> mVectorObjects; 	
 	std::map<std::string, Vector3> mDebugVectors; 
 	int showVectors(int vecswitch);
 
 	
 	Vector3 getGravity(){return  mGravity;} 
 	Vector3 getMagData(){return  mNorth;} 
};

}

#endif
